﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace Axe.Web.Controls
{
    public class MinutesList : HardcodedDropDownList
    {
        public MinutesList()
        {
            ToolTip = Resources.Control_Resources.MinutesList_ToolTip;
        }

        protected override HardcodedDropDownListEventArgs OnRequestDataItems()
        {
            HardcodedDropDownListEventArgs e = new HardcodedDropDownListEventArgs();

            int currentMin = DateTime.Now.Minute;

            for (int i = 0; i < 60; i++)
            {
                ListItem li = new ListItem();

                li.Text = i.ToString("d2");
                li.Value = i.ToString();
                if (i == currentMin)
                    li.Selected = true;

                e.BoundItems.Add(li);
            }

            return e;
        }

        [Bindable(true,BindingDirection.TwoWay)]
        public int SelectedMinute
        {
            get { return Int32.Parse(SelectedValue); }
            set { SelectedValue = value.ToString(); }
        }
    }

    public class HoursList : HardcodedDropDownList
    {
        public HoursList()
        {
            ToolTip = Resources.Control_Resources.HoursList_ToolTip;
        }

        protected override HardcodedDropDownListEventArgs OnRequestDataItems()
        {
            HardcodedDropDownListEventArgs e = new HardcodedDropDownListEventArgs();

            int currentH = DateTime.Now.Hour;

            for (int i = 0; i < 24; i++)
            {
                ListItem li = new ListItem();

                li.Text = i.ToString("d2");
                li.Value = i.ToString();

                if (i == currentH)
                    li.Selected = true;

                e.BoundItems.Add(li);
            }

            return e;
        }

        [Bindable(true, BindingDirection.TwoWay)]
        public int SelectedHour
        {
            get { return Int32.Parse(SelectedValue); }
            set { SelectedValue = value.ToString(); }
        }
    }
}
